//Date: 2025-02-10 12:25:03
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define P emplace_back
#define CLEAR(a,v) memset(a,(v),sizeof(a))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline int rd() {
    int s=0,m=0;char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')m=1;ch=getchar();}
    while( isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return m?-s:s;
}
bool MBE;
namespace SOLVER {
#define id(u,x) (u+x*n)
int n,rt,A,B,fa[100005],in[100005],out[100005],tim,dep[100005],st[20][100005],deg[300005],f[300005];
vector<int> g[100005],g1[300005];queue<int> q;void add(int u,int v) {g1[v].P(u),deg[u]++;}
int cmp(int x,int y) {return in[x]<in[y]?x:y;}
int lca(int x,int y) {
    if(x==y) return x;if(in[x]>in[y]) swap(x,y);int k=__lg(in[y]-in[x]);
    return cmp(st[k][in[x]+1],st[k][in[y]-(1<<k)+1]);
}
void dfs(int u,int p) {fa[u]=p,dep[u]=dep[p]+1,st[0][in[u]=++tim]=p;for(int v:g[u]) if(v!=p) dfs(v,u);out[u]=tim;}
int a[100005],t[100005],fl[100005];
void ADD(int x,int v) {for(int i=x;i<=n;i+=(i&-i)) t[i]+=v;}
int SUM(int x,int s=0) {for(int i=x;i;i-=(i&-i)) s+=t[i];return s;}
void dfs2(int u,int p) {a[++tim]=u;for(int v:g[u]) if(v!=p) dfs2(v,u);}
void MAIN() {
    cin>>n>>rt>>A>>B;rep(i,1,n-1) {int u=rd(),v=rd();g[u].P(v),g[v].P(u);}
    if(A<=B) {puts("1");return;}
    if(n>5000) {
        dfs2(rt,0);int ans=n+1;
        ADD(1,1),ADD(2,-1);rep(i,1,n) if(SUM(i)) fl[i]=1,ADD(i+A,1),ADD(i+A+B+1,-1);
        CLEAR(t,0);rep(i,1,n) if(fl[i]) {if(i+A<=n) ADD(i+A-B,1),ADD(i+A,-1);else ADD(i,1),ADD(i+B+1,-1);}
        rep(i,1,n) if(SUM(i)) ans=min(ans,a[i]);cout<<ans<<endl;return;
    }
    dfs(rt,0);rep(i,1,19) rep(j,1,n-(1<<i)+1) st[i][j]=cmp(st[i-1][j],st[i-1][j+(1<<i-1)]);
    rep(u,1,n) {
        rep(v,1,n) if(dep[u]+dep[v]-2*dep[lca(u,v)]<=B) {
            if(u!=v&&in[v]<=in[u]&&in[u]<=out[v]) 
                {for(int w:g[v]) if(w!=fa[v]&&in[w]<=in[u]&&in[u]<=out[w]) add(id(u,0),id(w,2));}
            else add(id(u,0),id(v,1));
        }
        rep(v,1,n) if(in[u]<=in[v]&&in[v]<=out[u]&&dep[v]-dep[u]==A) add(id(u,1),id(v,0));
        rep(v,1,n) if(in[fa[u]]<=in[v]&&in[v]<=out[fa[u]]&&dep[v]-dep[fa[u]]==A&&(in[u]>in[v]||in[v]>out[u])) add(id(u,2),id(v,0));
    }
    rep(i,1,n) f[i]=n+1;rep(i,n+1,n*3) f[i]=0;
    rep(i,1,n*3) if(!deg[i]) {
        q.push(i);int u=(i-1)%n+1;f[i]=n+1;
        if(i<=n*2) {rep(v,1,n) if(in[u]<=in[v]&&in[v]<=out[u]&&dep[v]-dep[u]<=B) f[i]=min(f[i],v);}
        else {rep(v,1,n) if(in[fa[u]]<=in[v]&&in[v]<=out[fa[u]]&&dep[v]-dep[fa[u]]<=B&&(in[u]>in[v]||in[v]>out[u])) f[i]=min(f[i],v);}
    }
    while(q.size()) {
        int u=q.front();q.pop();
        for(int v:g1[u]) {
            if(v<=n) f[v]=min(f[v],f[u]);else f[v]=max(f[v],f[u]);
            if(--deg[v]==0) q.push(v);
        }
    }
    cout<<f[id(rt,1)]<<endl;
}
}
bool MED;
signed main() {
    freopen("nim.in","r",stdin);freopen("nim.out","w",stdout);
    for(int tt=1;tt;tt--) SOLVER::MAIN();
    cerr<<(&MBE-&MED)/1024<<" KB, "<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
    return 0;
}